package exsun.jt808.data.media.data;


import exsun.jt808.data.util.parse.HexStrUtil;

import java.util.Date;

public class MsgPackage {
	//设备号
	private String phoneNum;
	//通道
	private int channel;
	private String clientIdChannel;// phone + "-" + cnl
	//数据类型 0：视频I帧 1：视频P帧 2：视频B帧 3：音频帧 4：透传数据
	private int dataType;
	private int pt;
	private byte[] data;// 消息数据
	public Date dt;
	public long nTimeStamp;
	public MsgPackage(String phoneNum, int clientIdChannel, int pt, int dataType,byte[] data, long nTimeStamp) {
		super();
		this.phoneNum = phoneNum;
		this.channel = clientIdChannel;
		this.clientIdChannel = phoneNum + "-" + clientIdChannel;
		this.pt=pt;
		this.dataType=dataType;
		this.data = data;
		this.dt = new Date();
		this.nTimeStamp = nTimeStamp;
	}

	public MsgPackage(String clientIdChannel, int pt, int dataType,byte[] data, long nTimeStamp) {
		super();
		String[] splits = clientIdChannel.split("_");
		if(splits.length == 2){
			this.phoneNum = splits[0];
			this.channel = Integer.parseInt(splits[1]);
		}
		this.clientIdChannel = clientIdChannel;
		this.pt=pt;
		this.dataType=dataType;
		this.data = data;
		this.dt = new Date();
		this.nTimeStamp = nTimeStamp;
	}

	public String getClientIdChannel() {
		return clientIdChannel;
	}

	public void setClientIdChannel(String clientIdChannel) {
		this.clientIdChannel = clientIdChannel;
	}

	public int getDataType() {
		return dataType;
	}

	public void setDataType(int dataType) {
		this.dataType = dataType;
	}

	public int getPt() {
		return pt;
	}

	public void setPt(int pt) {
		this.pt = pt;
	}

	public byte[] getData() {
		return data;
	}

	public void setData(byte[] data) {
		this.data = data;
	}

	public String getPhoneNum() {
		return phoneNum;
	}

	public void setPhoneNum(String phoneNum) {
		this.phoneNum = phoneNum;
	}

	public int getChannel() {
		return channel;
	}

	public void setChannel(int channel) {
		this.channel = channel;
	}

	@Override
	public String toString() {
		return "MsgPackage{" +
				"clientIdChannel='" + clientIdChannel + '\'' +
				", dataType=" + dataType +
				", pt=" + pt +
				", data=" + HexStrUtil.encodeHex(data) +
				'}';
	}
}
